package com.cavy.platform.client.service;

import com.cavy.platform.client.domain.ContainerInfo;
import com.cavy.platform.client.domain.ContainerRunningException;
import com.cavy.platform.client.domain.DockerEventHandler;

/**
 * @author 唐旭
 * @Date 2018/7/26
 */
public interface DockerService {
    String SUCCESS_EXIT_CODE = "0";
    String SPLIT = " ";
    String TAG = "tag";
    String FLUENTD_ADDRESS = "fluentd-address";
    String FLUENTD_ASYNC_CONNECT = "fluentd-async-connect";
    String LOG_DRIVER = "fluentd";
    String CONTAINER_PRE = "cavy-stage-";


    /**
     * 创建docker容器
     *
     * @param containerInfo domain信息
     */
    void createContainer(ContainerInfo containerInfo) throws ContainerRunningException;

    /**
     * 注册容器的事件处理器
     *
     * @param handler 事件处理器
     */
    void registerEventHandler(DockerEventHandler handler);

    /**
     * 启动容器
     *
     * @param dockerContainerId 容器id
     */
    void startContainer(String dockerContainerId) throws ContainerRunningException;

    /**
     * 移除容器
     * (容器未停止,则先停止,再移除)
     *
     * @param containerInfo 容器信息
     */
    void removeContainer(ContainerInfo containerInfo) throws ContainerRunningException;
}
